import scala.collection.mutable

/**
 * @title:
 * @author: zhang
 * @date: 2022/2/15 09:40 
 */
object TestMap {
  def main(args: Array[String]): Unit = {

    var map1 = mutable.Map(
      ("a",1),
      ("b",2),
      ("c",3)
    )

    var map2 = mutable.Map(
      ("a",4),
      ("d",5),
      ("c",6)
    )


    map2.foldLeft(map1)(
      (map,kv)=>{
        val k: String = kv._1
        val v: Int = kv._2
        val old: Int = map.getOrElse(k, 0)
        map.update(k,old+v)
        map
      }
    )

    print(map1)

  }

}
